<!DOCTYPE html>
<html lang="en">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>${_title}</title>

    <!-- Bootstrap core CSS -->

    <link href="${_css}/bootstrap.min.css" rel="stylesheet">

    <link href="${_font}/css/font-awesome.min.css" rel="stylesheet">
    <link href="${_css}/animate.min.css" rel="stylesheet">

    <!-- Custom styling plus plugins -->
    <link href="${_css}/custom.css" rel="stylesheet">
    <link href="${_css}/icheck/flat/green.css" rel="stylesheet">
    <link href="${_css}/datatables/tools/css/dataTables.tableTools.css" rel="stylesheet">
	<link rel="stylesheet" href="${_css}/base.css">
    <script src="${_js}/jquery.min.js"></script>
    <script src="${_js}/resize.js"></script>
	<script type="text/javascript" src="${_front_js}/jquery.page.js"></script>
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
          <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
          <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
        <![endif]-->
	<style>
		td a{
			cursor:pointer
		}
	</style>
</head>


<body style="background: #F7F7F7;">
<div class="">
    <div class="row">
        <div class="col-md-12 col-sm-12 col-xs-12">
            <div class="x_panel">
	            <div class="x_title">
					<h2>三方信息记录列表</h2>
					<div class="clearfix"></div>
				</div>
                <div class="pull-right">
                	<button id="query" type="button" class="btn btn-info">查询</button>
                	<button id="export" type="button" class="btn btn-primary export">导出</button>
                </div>
                <form class="form-horizontal form-label-left input_mask" id="thirdMsg">
                    <div class="col-md-2 col-sm-2 col-xs-6 form-group has-feedback">
                        <input type="text" class="form-control has-feedback-left" id="phone" value="<#if phone?exists>${phone}</#if>"
                        placeholder="输入手机号">
                        <span class="fa fa-user form-control-feedback left" aria-hidden="true"></span>
                    </div>
                     <div class="col-md-2 col-sm-2 col-xs-5 form-group has-feedback">
                        <select class="form-control" id="type" name="type">
                        	<option value="-1">--请选择信息类型--</option>
							<option value="0" <#if type?exists && type=="0">selected=selected </#if>>充值</option>
							<option value="1" <#if type?exists && type=="1">selected=selected </#if>>提现</option>
							<option value="22"<#if type?exists && type=="22">selected=selected </#if>>其他</option>
						</select>	
                    </div>
                    <form class="form-horizontal">
						<fieldset>
							<div class="control-group">
								<div class="controls">
									<div class="input-prepend input-group">
										<span class="add-on input-group-addon">
											<i class="glyphicon glyphicon-calendar fa fa-calendar"></i>
										</span>
										<input type="text" style="width: 200px" name="reservation" id="reservation" placeholder="请选择信息产生时间段"
										class="form-control" value="" />
									</div>
								</div>
							</div>
						</fieldset>
					</form>
                 </form>
                <div class="clearfix"></div>
            </div>
            <div class="scroll">
                <div class="x_content">
                    <table id="example" data-action="/admin/system/queryList?1=1" class="table table-striped responsive-utilities jambo_table">
                        <thead>
                            <tr class="headings">
                                <th>
                                    <input type="checkbox" class="tableflat">
                                </th>
                                <th>序号 </th>
                                <th>手机号 </th>
                                <th>信息类型</th>
                                <th>信息内容</th>
                                <th>创建时间 </th>
                            </tr>
                        </thead>
                        <tbody>
			                <#if (pageInfo.pageList?size > 0)>
								<#list pageInfo.pageList as model>
									<tr class="even pointer">
		                                <td class="a-center ">
		                                    <input type="checkbox" class="tableflat" data-id=${model.id}>
		                                </td>
		                                <td>
		                                	${model.id}
		                                </td>
		                                <td>
		                                <#if model.phone?exists>
		                                    ${model.phone}
		                                </#if>
		                                </td>
		                                <td>
		                                <#if model.type?exists>
		                                     <#if model.type =="0">
		                                                                           充值
		                                      <#elseif  model.type =="1">
		                                                                           提现
		                                      <#elseif  model.type =="22">
		                                                                          其他              
		                                      <#else>
		                                     </#if>
		                                </#if>
		                                </td>
		                                <td>
		                               <#if model.content?exists>
		                                    ${model.content}
		                                </#if>
		                                </td>
		                                <td>
		                                	<#if model.createTime?exists>
		                                		${(model.createTime?string("yyyy-MM-dd HH:mm:ss"))!}	       
		                                	</#if>
		                                </td>
		                             </tr>   
		                        </#list>
								<#else>
								<tr class="even pointer">
									<td colspan="11">无记录</td>
								</tr>
							</#if>
                        </tbody>
                    </table>
                    <#if (pageInfo.pageList?size > 0)>
	                	<#include "../base/Page.ftl">
	                </#if>
                </div>
            </div>
        </div>
        <br />
        <br />
        <br />
    </div>
</div>
                    
<script src="${_js}/bootstrap.min.js"></script>

<!-- bootstrap progress js -->
<script src="${_js}/progressbar/bootstrap-progressbar.min.js" type="text/javascript"></script>
<script src="${_js}/nicescroll/jquery.nicescroll.min.js" type="text/javascript"></script>
<!-- icheck -->
<script src="${_js}/icheck/icheck.min.js" type="text/javascript"></script>

<script src="${_js}/custom.js" type="text/javascript"></script>

<!-- PNotify -->
<script src="${_js}/notify/pnotify.core.js" type="text/javascript"></script>
<script src="${_js}/notify/pnotify.buttons.js" type="text/javascript"></script>
<script src="${_js}/notify/pnotify.nonblock.js" type="text/javascript" ></script>

<!-- daterangepicker -->
<script type="text/javascript" src="${_js}/datepicker/moment.min2.js"></script>
<script type="text/javascript" src="${_js}/datepicker/daterangepicker.js"></script>
<script type="text/javascript" src="${_front_js}/date.js"></script>

<script type="text/javascript">
    $(document).ready(function () {
        $('#reservation').daterangepicker(null, function (start, end, label) {
            //console.log(start.toISOString(), end.toISOString(), label);
        });
    });
</script>

<script>
    $(document).ready(function () {
        $('input.tableflat').iCheck({
            checkboxClass: 'icheckbox_flat-green',
            radioClass: 'iradio_flat-green'
        });
    });
</script>
<script>
	$(".btn-success").click(function(){
		window.location.href="/admin/system/queryList";
	});
	
	function initData(action) { 
		var phone = $.trim($("#phone").val());
	    var type = $.trim($("#type").find("option:selected").val());
		var reservation =$("#reservation").val();
        var reg = /^\d{4}[-]\d{2}[-]\d{2}~\d{4}[-]\d{2}[-]\d{2}$/;
		if(reservation !="" && !reg.test(reservation)){
			new PNotify({
		            	title: '操作提示',
		            	text: '时间格式错误！',
		            	delay: 3e3,
		            	type: 'error'
		        	});
		    return false;
		}
    	if(phone != ""){
    		action += "&phone="+phone;
    	}
    	if(type!=""){
    	    action += "&type="+type;
    	}
    	if(reservation !=""){
    		var splitChar = "~";
    		if(reservation.indexOf(splitChar) != -1){
    			var sendTimeFrom = reservation.split(splitChar)[0].trim();
    			var sendTimeTo = reservation.split(splitChar)[1].trim();
    			action += "&sendTimeFrom="+sendTimeFrom;
    			action += "&sendTimeTo="+sendTimeTo;
    		}
    	}
		window.location.href=action;
	} 
	
	
	
	$("#export").click(function(){
				var count=0;
				var ids=new Array();
			    var phone = $.trim($("#phone").val());
			    var type = $.trim($("#type").find("option:selected").val());
				$("tbody .tableflat").each(function(){
					if($(this).parent().hasClass('checked')){
						ids[count]=$(this).attr("data-id");
						count++;
					}
				})
				var action="/admin/export/thirdMsg?ids="+ids;
		    	var reservation = $("#reservation").val();
		    	var reg = /^\d{4}[-]\d{2}[-]\d{2}~\d{4}[-]\d{2}[-]\d{2}$/;
		    	if(reservation !="" && !reg.test(reservation)){
					new PNotify({
				            	title: '操作提示',
				            	text: '时间格式错误！',
				            	delay: 3e3,
				            	type: 'error'
				        	});
				    return false;
				}
				if(phone != ""){
		    		action += "&phone="+phone;
		    	}
		    	if(type!=""){
		    	    action += "&type="+type;
		    	}
		     	if(reservation !=""){
    		        var splitChar = "~";
		    	   	if(reservation.indexOf(splitChar) != -1){
		    			var sendTimeFrom = reservation.split(splitChar)[0].trim();
		    			var sendTimeTo = reservation.split(splitChar)[1].trim();
		    			action += "&sendTimeFrom="+sendTimeFrom;
		    			action += "&sendTimeTo="+sendTimeTo;
		    		}
	    	  }
				$("#thirdMsg").attr("method","post");
				$("#thirdMsg").attr("action",action);
				$("#thirdMsg").submit();
			});
	
	$(".btn-info").click(function(){
		initData($("#example").attr('data-action'));
	});
	
		var sendTimeFrom = "<#if sendTimeFrom?exists>${sendTimeFrom}</#if>";
		var sendTimeTo = "<#if sendTimeTo?exists>${sendTimeTo}</#if>";
		if(sendTimeFrom != "" && sendTimeTo != ""){
			document.getElementById("reservation").value=sendTimeFrom+"~"+sendTimeTo
		}
</script>
</body>

</html>